package com.groupseven.happycampus.common.instener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.groupseven.happycampus.common.bo.CardBo;
import com.groupseven.happycampus.common.pojo.Card;
import com.groupseven.happycampus.service.CardService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * @BeLongsProject: happycampus
 * @BeLongsPackage: com.groupseven.happycampus.common.instener
 * @Author: WRH
 * @CreateTime: 2022-07-27 19:45
 * @Description: TODO
 * @Version: 1.0
 */
@Component
@Scope("prototype")
public class WebCardListener extends AnalysisEventListener<CardBo> {

    @Autowired
    private CardService cardService;


    @Override
    public void invoke(CardBo data, AnalysisContext analysisContext) {
        System.out.println(data);
        Card card = new Card();
        BeanUtils.copyProperties(data,card);
        cardService.addCards(card);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }


}